#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5,M=2e4+5;
int T,a[N],n,cnt,la[3];
void dfs(int i,int col,int tot){
    if(i>n){
        cnt=max(cnt,tot);
        return;
    }
    // cout<<a[i]<<' '<<la[col]<<endl;
    if(a[i]==la[col])tot+=la[col];
    int tmp=la[col];
    la[col]=a[i];
    dfs(i+1,1,tot);
    dfs(i+1,2,tot);
    la[col]=tmp;
}
signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    //freopen("color.in","r",stdin);
    //freopen("color.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){
        int s=0;
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i],s+=a[i];
        if(n<=15){
            cnt=0;
            la[1]=la[2]=0;
            dfs(1,1,0);
            cout<<cnt<<endl;
            continue;
        }
        // for(int i=1;i<=n;i++){
        //     for(int j=i;j<=n;j++){
        //         int tot=0;
        //         for(int k=i+1;k<=j;k++){
        //             if(a[k-1]==a[k])tot+=a[k];
        //         }
        //         if(a[i]==a[j])tot+=a[j];
        //         f[i][j]=tot;
        //     }
        // }
        cout<<s/2<<endl;
    }
    return 0;
}
/*

The AC resolve is tree dp

But I don't like tree

*/